/**
 * @author LYJ
 * Created by Administrator on 2018/3/7 0007.
 */
function OrdersParticularsModal($modal) {
    var This = this;
    this.$modal = $modal;

    $(function () {
        This.init();
    });

    this.init = function () {
        this.$modal.modal({backdrop:true,show:false});
    };
    
    this.setData = function (orders) {
        this.class("userName").html(orders["userName"]);
        this.class("state").html(orders["state"]);
        this.class("totalPrices").html(orders["totalPrices"]);
        var tbody = this.class("orderfo").find("tbody");
        $.ajax({
            type:"post",
            data: "orderId=" + orders["orderId"],
            url:"orders/getOrderfo",
            success: function (data) {
                $.each(data, function (index,orderfo) {
                    tbody.html(
                        "<tr>"+
                        '<td>'+orderfo["foodName"]+'</td>'+
                        // '<td>'+orderfo["foodPrice"]+'</td>'+
                        '<td>'+orderfo["number"]+'</td>'+
                        '</tr>'
                    );
                });
            }
        });
    };
    
    this.clearData = function () {
        this.class("userName").html("");
        this.class("state").html("");
        this.class("totalPrices").html("");
        this.class("orderfo").find("tbody").html("");
    };
    
    
    this.show = function () {
        this.event.showBefore();
        This.$modal.modal("show");
        this.event.showAfter();
    };

    this.hide = function () {
        this.event.hideBefore();
        this.$modal.modal("hide");
        this.event.hideAfter();
    };
    
    this.class = function (className) {
        return this.$modal.find("."+className);
    };
    
    this.event = {
        showBefore: function () {},
        showAfter: function () {},
        hideBefore: function () {},
        hideAfter: function () {}
    }
}